package loengud.yksteist;

import java.io.IOException;

public class Test {

	static Test t = new Test();
	
	static Object lock = new Object();
	
	public static void main(String[] args) throws InterruptedException {
		
		Thread t1 = new Thread() {
			@Override
			public void run() {
				t.a();
			}
		};
		t1.start();
		
		Thread.sleep(250);
		
		Thread t2 = new Thread() {
			@Override
			public void run() {
				t.b();
			}
		};
		t2.start();
	}
	
	public void a() {
		synchronized (lock) {
			try {
				lock.wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		} // -s
		
		System.out.println("a");
	}
	
	public void b() {
		System.out.println("b");
		synchronized (lock) {
			lock.notifyAll();
		}
	}
}
